package com.gzz.orchid.context.infrastructure.definition;

import com.gzz.orchid.common.core.support.IBaseEnum;

/**
 * 客户等级
 *
 * @author higmd
 */
public enum Grade implements IBaseEnum {

    GENERAL(0, "普通"),
    VIP(1, "VIP"),
    SUPER(2, "超级"),
    GOLD(3, "黄金"),
    PLATINUM(4, "铂金");

    private final int code;
    private final String text;

    Grade(int code, String text) {
        this.code = code;
        this.text = text;
    }

    public static Grade parse(int val) {
        for (Grade e : Grade.values()) {
            if (e.code == val) {
                return e;
            }
        }
        throw new IllegalArgumentException("Invalid Grade value: " + val);
    }

    public static Grade of(String name) {
        return Enum.valueOf(Grade.class, name);
    }

    @Override
    public Integer getValue() {
        return code;
    }

    @Override
    public String getLabel() {
        return text;
    }
}
